﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Compilation;
using System.Web.UI;

namespace TathamOddie.OpenSearchValidator.WebUI
{
	public class UrlRewritingModule : IHttpModule
	{
		public void Init(HttpApplication context)
		{
			context.BeginRequest += new EventHandler(context_BeginRequest);
		}

		void context_BeginRequest(object sender, EventArgs args)
		{
			var context = HttpContext.Current;
			var request = context.Request;
			if (request.Path.EndsWith("/validate", StringComparison.OrdinalIgnoreCase))
			{
				context.RewritePath("~/Validate.aspx");
			}
		}

		public void Dispose()
		{
		}
	}
}